package com.histone.lilian.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
public interface AuthMapper {

    @Select("select role_id from sys_user_role where user_id = #{userId}")
    List<String> getRoleList(Object userId);

//    @Select({
//            "<script>",
//            "select perms from sys_menu where menu_id in (select menu_id from sys_role_menu where role_id in ",
//            "<foreach collection='roleIdList' item='item' open='(' separator=',' close=')'>",
//            "#{item}",
//            "</foreach>",
//            ")</script>"
//    })
    @Select("select perms from sys_menu where menu_id in (" +
                "select menu_id from sys_role_menu where role_id in (" +
                    "select role_id from sys_user_role where user_id = #{userId}" +
                ")" +
            ")")
    List<String> getPermissionList(Object userId);
}
